<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>中国传媒大学设备预约平台</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="{$projectUrl}/css/admin_style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="{$projectUrl}/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="{$projectUrl}/js/jquery.cycle.all.min.js"></script>
<script type="text/javascript" src="{$projectUrl}/js/globalJsFunction.js"></script>
<script type="text/javascript" src="{$projectUrl}/js/calendar/calendar.js"></script>
<script type="text/javascript" src="{$projectUrl}/js/calendar/WdatePicker.js"></script>

<script type="text/javascript">
{literal}
$(document).ready(function(){
    $('#slideshow').cycle({
        fx:     'fade',
        speed:  'slow',
        timeout: 3000,
        pager:  '#slider_nav',
        pagerAnchorBuilder: function(idx, slide) {
            // return sel string for existing anchor
            return '#slider_nav li:eq(' + (idx) + ') a';
        }
    });
});
{/literal}
</script>
</head>
<body>
<div class="main">
  <div class="main_resize">
    <div class="main_left">
      {include file=include/headerLogo.html}
      <div class="clr"></div>
      {include file=include/opencourseLeftMenu.html}
      <div class="clr"></div>
    </div>
    <div class="main_right">
      {include file=include/headerLogin.html}

      <div class="clr" style="background-color:#C63; height:1px;">&nbsp;</div>
      <div>
      {include file=include/adminTopMenu.html}
      </div>
      <div class="clr">
      	<p><img src="{$projectUrl}/images/addCamera.jpg" width="30px" height="20px"><span style="font-color:#C60; font-size:16px;">添加设备</span>
          <span style="font-color:#C60; font-size:16px; display:inline;"></span>(总个数:{$coursesNumber})</p>
      	 <!--创建设备-->

                <div id = "create_user_name" style="font-size:14px;">
                <form action="opencourse.php?action=addcourse" method="post">
                <input type="hidden" name="action" id="action" value="addcourse"/>
                <input type="hidden" name="teacherid" id="teacherid" value="{$userId}"/>
                    <table bgcolor="#FFFFFF" width="100%" style="font-size:14px">
                    	<tr>
                    		<td><span style="color:RED">*</span>课名</td>
                    		<td>课代表学号</td>
                    		<td>预约次数</td>
                    		<td>开始时间</td>
                    		<td>结束时间</td>
                    		<td>介绍</td>
                    	</tr>
                    	<tr>
                    		<td><input type="text" id="name" name="name" size="30"/></td>
                    		<td>
                    			<input type="text" id="monitorid" name="monitorid" size="10"/>
                    		</td>
                    		<td>
                        		<input type="text" id="booktime" name="booktime" size="6" value="10"/>
                    		</td>
                    		<td>
                    			<input class="Wdate" type="text" id="begintime" name="begintime" onClick="WdatePicker()">
                    		</td>
                    		<td>
                    			<input class="Wdate" type="text" id="endtime" name="endtime" onClick="WdatePicker()">
                    		</td>
                    		<td><input type="image" src="{$projectUrl}/images/add1.jpg" class="button"/></td>
                    	</tr>
                    </table>
                </form>
                </div>
                <div>
                  <span style="align:center; color:red; font-size:12px">{$insertMessage}</span>
                  </div>
                <!--创建用户结束-->
      </div>

      <!-- 搜索用户并且进行修改 -->
      <div class="clr">
       <!--全部用户的列表-->
                <div>
                	<p><span>{if $searchNote eq ""}输入教师ID或者教师名字或者课程名字进行搜索
                		{else}{$searchNote}
                		{/if}
                		</span>
                		<span style="float:right">
					        <form id="form1" name="form1" method="get" action="opencourse.php">
					        		<input type="hidden" name="action" id="action" value="searchCourse"/>
                      <input type="text" class="keywords" id="keyword" name="keyword" maxlength="50" value=""/>
                      <input name="b" type="submit" class="button" value="搜索" />
					        </form>
					        </span></p>
                <form id="courselist_form" action="opencourse.php?action=deletecourse&pageIndex={$pageIndex}" method="post" onsubmit="return window.confirm('确定删除？');">
                <input type="hidden" name="action" id="action" value="deletecourse"/>
                    <table width="100%" bgcolor="#FFFFFF" style="font-size:14px;">
                    <tr valign="top"  style="background-color:#C60">
                        <td>({$courses|@count})</td>
                        <td>名称</td>
                        <td>教师</td>
                        <td>课代表</td>
                        <td>预约次数</td>
                        <td>开始时间</td>
                        <td>结束时间</td>
                        <td>介绍</td>
                        <td>操作</td>
                    </tr>
                    {foreach from=$courses item=course name=courselist}
                    <tr valign="top" onmouseout="this.style.backgroundColor=''"onmouseover="this.style.backgroundColor='#AAAAAA'">
                        <td><input type="checkbox" id="courses[]" name="courses[]" value="{$course.id}"/></td>
                        <td><span title="{$course.name}">{$course.name|truncate:20:""|escape:'html'}</span></td>
                        <td><span title="{$course.teacherid}">{$course.teacherid|truncate:20:""|escape:'html'}</span></td>
                        <td><span title="{$course.monitor}">{$course.monitor}</span></td>
                        <td>{$course.booktime}</td>
                        <td><span title="{$course.begindate}">{$course.begindate|truncate:12:""}</span></td>
                        <td><span title="{$course.enddate}">{$course.enddate|truncate:12:""}</span></td>
                        <td><span title="{$course.info}">{$course.info|truncate:60:"..."|escape:'html'}</span></td>
                        <td><a href="opencourse.php?action=edit&id={$course.id}&pageIndex={$pageIndex}#editCourseDiv">编辑</a></td>
                    </tr>
                    {/foreach}


                    <tr><td align="right" colspan="2">
                        <input type="button" value="全选" onclick='chkall("courselist_form")' />
                        <input type="reset" value="不选" />
                        </td>
                        <td align="left" colspan="3">
                        <input type="submit" value="删除选中"/>
                        </td>
                    </tr>
                     <tr>
                    <td colspan="8" align="center">
                    <a href="opencourse.php?pageIndex={$leftPageIndex}">&lt;</a>

                    {section start=$leftMostPageIndex loop=$pageIndex step=1 name=pagesection}
                    <a href="opencourse.php?pageIndex={$smarty.section.pagesection.index}">
                    {$smarty.section.pagesection.index}&nbsp;&nbsp;
                    </a>
                    {/section}
                    <span style="font-size:18px;"><Strong><bold>{$pageIndex}</bold></Strong>&nbsp;</span>
                    {section start=$pageIndex+1 loop=$rightMostPageIndex+1 step=1 name=rightpagesection}
                    <a href="opencourse.php?pageIndex={$smarty.section.rightpagesection.index}">
                    {$smarty.section.rightpagesection.index}&nbsp;&nbsp;
                    </a>
                    {/section}

                    <a href="opencourse.php?pageIndex={$rightPageIndex}">&gt;</a>
                    </td>
                    </tr>
                    </table>
                </form>
                </div>
                <!--全部用户的列表-->
      </div>
      <!-- 搜索用户并且进行修改 结束-->
      <div class="clr"></div>
      <!-- 编辑课程 -->
      {if $editCourse.id neq ''}
      <div class="clr" id="editCourseDiv">
      	<p><img src="{$projectUrl}/images/img_1.jpg" width="30px" height="30px"><span style="font-color:#C60; font-size:16px;">编辑课程</span></p>
                <div id = "modify_course" style="font-size:14px;">
                <form action="opencourse.php?id={$editCourse.id}&pageIndex={$pageIndex}#editCourseDiv" method="post">
                <input type="hidden" name="action" id="action" value="modifycourse"/>
                <input type="hidden" name="courseid" id="courseid" value="{$editCourse.id}"/>
                    <table bgcolor="#FFFFFF" width="100%" style="font-size:14px;">
                    	<tr>
                    		<td>课程名字</td><td><input type="text" id="name" name="name" size="14" value="{$editCourse.name}"/></td>
                    	</tr>
                    	<tr>
                    		<td>教师</td><td><input type="text" id="teacherid" name="teacherid" size="14" value="{$editCourse.teacherid}"/></td>
                    		</tr>
                    	<tr>
                    		<td>班长</td><td><input type="text" id="monitor" name="monitor" size="14" value="{$editCourse.monitor}"/></td>
                    		</tr>
                    	<tr>
                    	<td>开始时间</td>
                    	<td><input class="Wdate" type="text" id="begindate" name="begindate" onClick="WdatePicker()" value="{$editCourse.begindate}" /><td>
                    	</tr>
                    	<tr><td>结束时间</td>
                    			<td><input class="Wdate" type="text" id="enddate" name="enddate" onClick="WdatePicker()" value="{$editCourse.enddate}"/></td>
                    	</tr>
                    	<tr>
                    		<td>介绍</td><td><textarea id="info" name="info">{$editCourse.info}</textarea></td>
                    	</tr>
                    <tr>
                    		<td>保存</td><td><input type="image" src="{$projectUrl}/images/save.jpg" class="button"/></td>
                    	</tr>
                    </table>
                </form>
                </div>
      </div>
      
      <div class="clr" id="listtheusersordevices"> 
      	<p>
      		<span><a href="opencourse.php?id={$editCourse.id}&pageIndex={$pageIndex}&list=user#listtheusersordevices">列出课程下的用户</a></span>
      		<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
      		<span><a href="opencourse.php?id={$editCourse.id}&pageIndex={$pageIndex}&list=device#listtheusersordevices">列出课程下的设备</a></span>
      	</p>
      </div>
      
      <div class="clr" id="saveremovecourselistdiv"> 
      	<table width="100%" bgcolor="#FFFFFF" style="font-size:14px;">
      		<tr valign="top"  style="background-color:#C60">
                    		<td>编号</td>
                        <td>名字</td>
                        <td>删除</td>
          </tr>
      		{if $listItem eq "user"}
      			{foreach from=$courseUsers item=user name=courseUserslist}
                    <tr valign="top"  onmouseout="this.style.backgroundColor=''"onmouseover="this.style.backgroundColor='#AAAAAA'">
                        <td>{$user.uid}</td>
                        <td>{$user.name}</td>
                        <td><a href="opencourse.php?action=removelistitem&list=user&id={$editCourse.id}&uid={$user.uid}&pageIndex={$pageIndex}#saveremovecourselistdiv">
                        	<span style="color:#red">删除</span>
                        	</a></td>
                    </tr>
                    {/foreach}
          {elseif $listItem eq "device"}
                    {foreach from=$courseDevices item=device name=courseKidslist}
                    <tr valign="top"  onmouseout="this.style.backgroundColor=''"onmouseover="this.style.backgroundColor='#AAAAAA'">
                        <td>{$device.barcode}</td>
                        <td>{$device.name}</td>
                        <td><a href="opencourse.php?action=removelistitem&list=device&id={$editCourse.id}&deviceid={$device.did}&pageIndex={$pageIndex}#saveremovecourselistdiv">
                        	<span style="color:#red">删除</span>
                        	</a></td>
                    </tr>
                    {/foreach}
          {/if}
                    </table>	
      </div>
      
      {/if}
      <!-- 编辑用户结束 -->

    </div>
    <div class="clr"></div>
  </div>
  <div class="footer">
    {include file=include/footer.html}
  </div>
</div>
<div align=center></div></body>
</html>
